/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.awt.Point;
import java.util.ArrayList;

/**
 *
 * @author Morten
 */
public class King extends ChessPiece1 {

    private Point position;

    public King(String name, boolean color, Point position) {
	super(name, color, position);
	this.position = position;
    }

    @Override
    public ArrayList<Point> possibleMoves() {
	ArrayList<Point> possibleMoves;
	possibleMoves = new ArrayList<>();
	for (int i = 0; i < 9; i++) {
	    for (int j = 0; i < 9; j++) {
//		(i == position.getX() + 1 &&
//			(j == position.getY() - 1 ||
//			j == position.getY() || 
//			j == position.getY() + 1))||
//		(i == position.getX() - 1 &&
//			(j == position.getY() - 1 ||
//			j == position.getY() ||
//			j == position.getY() + 1))||
//		(i == position.getX() &&
//			(j == position.getY() - 1 ||
//			j == position.getY() + 1))
		if ((i == position.getX() + 1 && (j == position.getY() - 1 || j == position.getY() || j == position.getY() + 1)) || (i == position.getX() - 1 && (j == position.getY() - 1 || j == position.getY() || j == position.getY() + 1)) || (i == position.getX() && (j == position.getY() - 1 || j == position.getY() + 1))) {
		    if (canMoveTo(i, j)) {
			possibleMoves.add(new Point(i, j));
		    }
		}

	    }

	}
	return possibleMoves;
    }
}
